# -*- coding : utf_8 -*-
"""
=======================================
Time : 2025/4/13 12:09
Author : 田霄汉
Email : 522989570@qq.com
File : combat_class12.py
Project : pandas_demo
Function : 散点图，直方图，密度图和correlation相关性
=======================================
"""
import pandas as pd
import matplotlib.pyplot as plt
from config.setting import file_path

# 设置显示最长列数是777，防止出现显示省略号...
pd.options.display.max_columns = 777
combat12_path = file_path['excel_path'] + '/combat12.xlsx'
homes = pd.read_excel(combat12_path,
                      skiprows=3,
                      usecols='C:K',
                      index_col='id')

# # 制作散点图
# homes.plot.scatter(x='sqft_living', y='price')

# # 制作直方图，参数bins=100设置柱的粗细，y轴是frequency，就是频率
# homes.sqft_living.plot.hist(bins=100)
# # 设置x轴的密度
# plt.xticks(range(0, max(homes.sqft_living), 500), fontsize=12, rotation=90)

# # 制作密度图，需要安装scipy库，y轴是density，就是密度
# homes.sqft_living.plot.kde()
# plt.xticks(range(0, max(homes.sqft_living), 500), fontsize=12, rotation=90)

# # 显示图
# plt.tight_layout()
# plt.show()

# 查看table的字段correlation相关性
print(homes.corr())
